A magnetic sensor device is used as a sensor for detecting an open/close state in a flip mobile phone, a notebook computer, or the like and as a sensor for detecting a rotary position of a motor or the like (see, for example, Patent Literature 1). FIG. 15 illustrates a circuit diagram of the magnetic sensor device. In the magnetic sensor device, a magnetoelectric conversion element (such as Hall element) outputs a voltage corresponding to (typically, substantially proportional to) magnetic field intensity (or magnetic flux density), the output voltage is amplified by an amplifier, and a comparator is used to determine whether the amplified output voltage is larger or smaller than a predetermined magnetic field intensity or magnetic flux density (the result is output as a binary value, H signal or L signal).
In general, the output voltage of the magnetoelectric conversion element is minute, and hence there is a problem in that an error may occur due to an offset voltage of the magnetoelectric conversion element (element offset voltage), an offset voltage of the amplifier or the comparator (input offset voltage), and noise of those components, and the accuracy may be lower. The element offset voltage is generated mainly by stress on the magnetoelectric conversion element received from a package. The input offset voltage is generated mainly by characteristic fluctuations in elements of an input circuit of the amplifier or the comparator. The noise is generated mainly by flicker noise of a single transistor of the circuit or thermal noise of a single transistor or a resistive element.
The magnetic sensor device illustrated in FIG. 15 is configured as follows in order to reduce the influence of the offset voltages of the magnetoelectric conversion element and the amplifier. The magnetic sensor device includes a Hall element 1501, a switch circuit 1502 for switching the Hall element 1501 between a first detection state and a second detection state, a differential amplifier circuit 1503 for amplifying a voltage difference (V1−V2) of two output terminals of the switch circuit 1502, a capacitor 1504 having one end connected to one output terminal of the differential amplifier circuit 1503, a switch 1506 connected between the other output terminal of the differential amplifier circuit 1503 and the other end of the capacitor 1504, and a comparator 1505.
In this case, in the first detection state, a power supply voltage is input from terminals A and C, and a detection voltage is output from terminals B and D. In the second detection state, the power supply voltage is input from the terminals B and D, and a detection voltage is output from the terminals A and C. A differential signal voltage (hereinafter referred to as “element signal voltage”) of the Hall element 1501 corresponding to the magnetic field intensity is represented by Vh, an offset voltage (hereinafter referred to as “element offset voltage”) of the Hall element 1501 is represented by Voh, the gain of the differential amplifier circuit 1503 is represented by G, and an input offset voltage of the differential amplifier circuit 1503 is represented by Voa. The element signal voltages Vh in the first detection state and the second detection state are represented by Vh1 and Vh2, respectively, and the element offset voltages Voh in the first detection state and the second detection state are represented by Voh1 and Voh2, respectively.
The element offset voltages of the Hall element 1501 may be canceled out by a known method, typically called “spinning current”. Specifically, the switch circuit is switched so as to obtain an element offset component that is reverse in phase to a common-mode signal component (or an element offset component that is in-phase to a normal-mode signal component), thereby cancelling out the offset components. Due to the spinning current, Vh2 becomes substantially equal to Vh1, and Voh2 becomes substantially equal to Voh1. V1−V2=Vh1+Voh1 is established in the first detection state, and V1−V2=−Vh2+Voh2 is established in the second detection state.
In the first detection state, the switch 1506 is turned ON, and Vc1=(V3−V4)=G×(V1−V2)=G×(Vh1+Voh1+Voa) is charged in the capacitor 1504. Subsequently, in the second detection state, the switch 1506 is turned OFF, and V3−V4=G×(V1−V2)=G×(−Vh2+Voh2+Voa) is output from the differential amplifier circuit 1503.
From the above, a differential input voltage of the comparator 1505 in the second detection state is determined as follows.
                                          V            ⁢                                                  ⁢            5                    -                      V            ⁢                                                  ⁢            6                          =                ⁢                              (                                          V                ⁢                                                                  ⁢                3                            -                              Vc                ⁢                                                                  ⁢                1                                      )                    -                      V            ⁢                                                  ⁢            4                                                  =                ⁢                              (                                          V                ⁢                                                                  ⁢                3                            -                              V                ⁢                                                                  ⁢                4                                      )                    -                      Vc            ⁢                                                  ⁢            1                                                  =                ⁢                              G            ×                          (                                                                    -                    Vh                                    ⁢                                                                          ⁢                  2                                +                                  Voh                  ⁢                                                                          ⁢                  2                                +                Voa                            )                                -                      G            ×                                                          ⁢                  (                                    Vh              ⁢                                                          ⁢              1                        +                          Voh              ⁢                                                          ⁢              1                        +            Voa                    )                                        =                ⁢                              G            ×                          (                                                                    -                    Vh                                    ⁢                                                                          ⁢                  1                                -                                  Vh                  ⁢                                                                          ⁢                  2                                            )                                +                      G            ×                          (                                                Voh                  ⁢                                                                          ⁢                  2                                -                                  Voh                  ⁢                                                                          ⁢                  1                                            )                                          The influence of the input offset voltage is canceled out, and because Voh2 is substantially equal to Voh1, the influence of the element offset voltage is also canceled out.
In this manner, a compact and inexpensive magnetic sensor can be realized, which is capable of obtaining an output with small fluctuations without being affected by the input offset voltage.